//
//  WJImageCropperController.m
//  JerryIos
//
//  Created by 王军 on 2018/2/13.
//  Copyright © 2018年 王军. All rights reserved.
//

#import "WJImageCropperController.h"
#import "RSKImageCropper.h"


@interface WJImageCropperController () <RSKImageCropViewControllerDelegate>

@end

@implementation WJImageCropperController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"RSKImageCropper";
}

- (IBAction)changeAvatar:(id)sender {
    UIImage *photo = [UIImage imageNamed:@"gril_01"];
    RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:photo cropMode:RSKImageCropModeCircle];
    imageCropVC.cropMode = RSKImageCropModeSquare;
    imageCropVC.delegate = self;
    [self.navigationController pushViewController:imageCropVC animated:YES];
}

#pragma mark - RSKImageCropViewControllerDelegate

- (void)imageCropViewControllerDidCancelCrop:(RSKImageCropViewController *)controller {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect rotationAngle:(CGFloat)rotationAngle {
    self.avatarImage.image = croppedImage;
    [self.navigationController popViewControllerAnimated:YES];
}

@end
